﻿using System.Data;
using System.Data.SqlClient;

namespace _基础练习
{
    public static class SqlHelper
    {
        public static void ExecuteQuery(string connString,CommandType type,string sqlText, params SqlParameter[] para)
        {
            using (SqlConnection conn=new SqlConnection(connString))
            {
                conn.Open();
                using (SqlCommand cmd=new SqlCommand())
                {
                    cmd.Connection = conn;
                    cmd.CommandType = type;
                    cmd.CommandText = sqlText;
                    cmd.Parameters.Add(para);
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
                conn.Dispose();
            }
        }
    }
}